﻿namespace jzgl.Controller
{
    using jzgl.Model;
    using System;
    using System.Data;
    using System.Data.SqlClient;

    public class BudgetBargainDB
    {
        private SqlConnection conn = null;
        private ConnDB conndb = new ConnDB();
        private DataTable table = null;

        public BudgetBargainDB()
        {
            this.conn = this.conndb.GetConnString();
        }

        public int Add_BudgetBargain(BudgetBargain bb)
        {
            int num = 0;
            try
            {
                try
                {
                    string sql = string.Concat(new object[] { 
                        "insert into BudgetBargain (BudBarKey,BudBarNum,BudBarDate,BudBarState,BudBarCard,BudBarFirstPay,BudBarTotal,BudBarStartDate,BudBarEndDate,BudBarIsClean,BudBarRemark) values('", bb._BudBarKey, "','", bb._BudBarNum, "','", bb._BudBarDate, "','", bb._BudBarState, "','", bb._BudBarCard, "','", bb._BudBarFirstPay, "','", bb.BudBarTotal1, "','", bb._BudBarStartDate, 
                        "','", bb._BudBarEndDate, "','", bb._BudBarIsClean, "','", bb._BudBarRemark, "')"
                     });
                    num = this.conndb.Execute_Sql(sql);
                }
                catch (Exception)
                {
                    throw;
                }
            }
            finally
            {
            }
            return num;
        }

        public int Delete_BudgetBargain(BudgetBargain bb)
        {
            int num = 0;
            try
            {
                try
                {
                    string sql = "delete from BudgetBargain where BudBarKey='" + bb._BudBarKey + "'";
                    num = this.conndb.Execute_Sql(sql);
                }
                catch (Exception)
                {
                }
            }
            finally
            {
            }
            return num;
        }

        public int Delete_BudgetBargainBy_budListKey(string BudBarKey)
        {
            int num = 0;
            try
            {
                try
                {
                    string sql = "delete from BudgetBargain where BudBarKey='" + BudBarKey + "'";
                    num = this.conndb.Execute_Sql(sql);
                }
                catch (Exception)
                {
                }
            }
            finally
            {
            }
            return num;
        }

        public DataTable Show_BudgetBargain()
        {
            try
            {
                try
                {
                    string sql = "select * from BudgetBargain";
                    this.table = this.conndb.FillDataTable(sql);
                }
                catch (Exception)
                {
                }
            }
            finally
            {
            }
            return this.table;
        }

        public DataTable Show_BudgetBargain(string bud_key)
        {
            try
            {
                try
                {
                    string sql = "select * from BudgetBargain where BudBarKey='" + bud_key + "'";
                    this.table = this.conndb.FillDataTable(sql);
                }
                catch (Exception)
                {
                }
            }
            finally
            {
            }
            return this.table;
        }

        public DataTable Show_BudgetBargainBy_BudgetId(string key)
        {
            try
            {
                try
                {
                    string sql = "select * from BudgetBargain where BudBarKey='" + key + "'";
                    this.table = this.conndb.FillDataTable(sql);
                }
                catch (Exception)
                {
                }
            }
            finally
            {
            }
            return this.table;
        }

        public int Update_BudgetBargain(BudgetBargain bb)
        {
            try
            {
                try
                {
                }
                catch (Exception)
                {
                }
            }
            finally
            {
            }
            return 0;
        }
    }
}

